<template>
    <div>
          <el-table highlight-current-row style="width: 100%; margin: 20px 0;" border :data="tableData1">
            <el-table-column type="index" width="100" label="编号" align="center"></el-table-column>
            <el-table-column prop="name" label="类型名称" width="width" align="center"></el-table-column>
            <el-table-column prop="price" label="价格" width="width" align="center">
            </el-table-column>
            <el-table-column label="图片" width="width" align="center">
              <template slot-scope="{ row,$index}">
                        <img style=" width: 100px;height: 100px;" :src="row.mainImage">
              </template>
            </el-table-column>
        </el-table>
    </div>
</template>

<script>
export default {
    name:'classification',
     data() {
      return {
        tableData: [{
          name: '王小虎',
          price:'红色',
          // mainImage:""
        },
        {
          name: '王小虎',
          price:'红色',
          // mainImage:""
        }
        ]
        ,
        tableData1:[],
      }
    },
    mounted(){
          this.getcommodity()
    },
      methods: {
        //获取指定id的数据
       async getcommodity(){
          console.log(this.$route.query._id)
          // let _id = parseInt(this.$route.query._id)

          // console.log(typeof id)
         const result = await this.$API.mockCommodityId(this.$route.query._id) 
         console.log("获取指定id的数据",result)
         result.data.data
        let a = this.tableData1.push(result.data.data)
        console.log(a)
        }
       
    }
};
</script>

<style scoped lang="less">

</style>
